package leetcode_day._2022._202202._0110;

import java.util.HashMap;
import java.util.Map;

/**
 * @author yzh
 * @version 1.0
 * @date 2022/2/6 21:17
 * 唯一元素的和
 * 算法：哈希表
 */
public class _06_1748 {

    public int sumOfUnique(int[] nums) {
        int ans = 0;
        Map<Integer, Integer> map = new HashMap<>();
        for (int num : nums) map.put(num, map.getOrDefault(num, 0) + 1);
        for (int num : nums) if (map.get(num) == 1) ans += num;
        return ans;
    }

}
